# Contributor: Damian Kurek <starfire24680@gmail.com>
# Maintainer: Damian Kurek <starfire24680@gmail.com>
pkgname=kodi-game-libretro-beetle-pce-fast
pkgver=0.9.38.17
_realname=Matrix
pkgrel=0
pkgdesc="Beetle-PCE-fast for Kodi"
options="!check" # no test suite
url="https://github.com/kodi-game/game.libretro.beetle-pce-fast"
arch="x86 x86_64 aarch64 armv7" # kodi
license="GPL-2.0-only"
makedepends="cmake kodi-dev"
depends="kodi-game-libretro libretro-beetle-pce-fast"
source="$pkgname-$pkgver-$_realname.tar.gz::https://github.com/kodi-game/game.libretro.beetle-pce-fast/archive/$pkgver-$_realname.tar.gz"
builddir="$srcdir/game.libretro.beetle-pce-fast-$pkgver-$_realname"

build() {
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_MODULE_PATH=/usr/lib/cmake/kodi \
		-DUSE_LTO=1
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
	rm -r "$pkgdir"/usr/share/kodi/addons/game.libretro.beetle-pce-fast/resources/icon.png \
		"$pkgdir"/usr/share/kodi/addons/game.libretro.beetle-pce-fast/resources/screenshot* \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.beetle-pce-fast/game.libretro.beetle-pce-fast.so
	ln -s /usr/lib/libretro/mednafen_pce_fast_libretro.so \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.beetle-pce-fast/game.libretro.beetle-pce-fast.so
	sed -i '/<assets>/,/<\/assets>/d' "$pkgdir"/usr/share/kodi/addons/game.libretro.beetle-pce-fast/addon.xml
}

sha512sums="4de653f1973f1115d9cdc98440d7d572a205998ee853199ba7e6a20f397558c413415607601877a15068aa0895571ead1b2f16fa242406de2c7950b423705721  kodi-game-libretro-beetle-pce-fast-0.9.38.17-Matrix.tar.gz"
